/**
 * Created by root on 2017-11-25.
 */
// 系统配置
var config = {
    //baseUrl:"http://121.42.165.44/ksd-app/",
    // baseUrl:"http://47.94.22.93:8080/ksd-app1/",
    baseAddress:"http://base.ethepoch.com/",

    commPost:function (url,params,onSuccess) {
        $.ajax({url:url,
            data:params,
            type:"post",
            success:function (data) {
                if(data.status==200){
                    onSuccess(data.data);
                }else if(data.status==201){
                    location.href="login.html";
                }else {
                    alert(data.msg);
                }
            }
        })
    },
    commPostStatus:function (url,params,onSuccess) {
        $.ajax({url:config.baseUrl+url,
            data:params,
            type:"post",
            success:function (data) {
                onSuccess(data.status,data.data);
            }
        })
    },
    commGet:function (url,params,onSuccess) {
        $.ajax({url:url,
            data:params,
            type:"get",
            success:function (data) {
                if(data.status==200){
                    onSuccess(data.data);
                }else if(data.status==201){
                    location.href="login.html";
                }else {
                    alert(data.msg);
                }
            }
        })
    },
    isPc:function() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    },
    formatDateTime:function (date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h=h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        minute = minute < 10 ? ('0' + minute) : minute;
        var second=date.getSeconds();
        second=second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    },
    getTime:function (time) {
        var  date=new Date(time);
        return config.formatDateTime(date);
    },
    openPageLayer:function (title,url) {
        layer.open({
            type: 2,
            title:title,
            content: "/page/"+url //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
            ,area: ['500px', '350px']
            ,cancel: function(index, layero){
               location.reload();
            }
        });
    },
    openLayer:function (title,url) {
        layer.open({
            type: 2,
            title:title,
            content: url //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
            ,area: ['500px', '350px']
            ,cancel: function(index, layero){
                location.reload();
            }
        });
    },
    openIdLayer:function (id,title,url) {
        parent.layer.open({
            id:id,
            type: 2,
            title:title,
            content: url //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
            ,area: ['500px', '350px']
            ,cancel: function(index, layero){
                location.reload();
            }
        });
    },
    getLeave:function (leav) {
        var  leavel="未知";
         switch (leav){
             case 1:
                  leavel="大区负责";
                  break;
             case 2:
                 leavel="省代";
                  break;
             case 3:
                 leavel="市代";
                  break;
             case 4:
                 leavel="区县代";
                 break;
             case 5:
                 leavel="有限合伙企业";
                break;
             case 6:
                 leavel="副总裁";
                 break;
             case 7:
                 leavel="销售经理";
                 break;
             case 8:
                 leavel="销售主管";
                 break;
             case 9:
                 leavel="创客";
                 break;
             case 10:
                 leavel="钻石会员";
                 break;
         }
         return leavel;
    },
    getOrderStatus:function (leav) {
        var  leavel="";
        switch (leav){
            case 0:
                leavel="待付款";
                break;
            case 1:
                leavel="待发货";
                break;
            case 2:
                leavel="待收货";
                break;
            case 3:
                leavel="已完成";
                break;
            case 4:
                leavel="退款中";
                break;
            case 5:
                leavel="已退款";
                break;
        }
        return leavel;
    },
    accountType:function (type) {
        var  accountType;
        switch (type){
            case 0:
                accountType="我的账户";
                break;
            case 1:
                accountType="消费账户";
                break;
            case 2:
                accountType="红包账户";
                break;
            case 3:
                accountType="分享账户";
                break;
            case 4:
                accountType="兑换账户";
                break;
            case 5:
                accountType="CUC账户";
                break;
        }
        return accountType;
    },
    logType:function (type) {
        var  types="";
        switch (type){
            case 1:
                types="订单支付";
        }
        return types;
    },
    accountTypes:function () {
        var  normal={name:"普通账户",value:"0"};
        var  xf={name:"消费账户",value:"1"};
        var  hb={name:"红包账户",value:"2"};
        var  fx={name:"分享账户",value:"3"};
        var  dh={name:"兑换账户",value:"4"};
        var  datas=new Array();
        datas.push(normal);
        datas.push(xf);
        datas.push(hb);
        datas.push(fx);
        datas.push(dh);
        return datas;
    },
    getQueryString:function(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
      }
}




